<?php
class Admin_Forms_LoginForm extends Zend_Form {

	function init() {
		$this->setAction('')
				->setMethod('POST')
				->setAttrib('class','form-inline');
		$user_name = $this->createElement('text', 'user_name');
		$user_name->addValidator('alnum')
					->addValidator ( 'regex', false, array ('/^[a-z]+/' ) )
		            ->addValidator ( 'stringLength', false, array (5, 20 ) )
		            ->setRequired ( true )
		            ->addFilter ( 'StringToLower' )
		            ->addFilter('StringTrim')
		            ->setAttrib('class','input-medium')
		            ->setLabel('Tài khoản');
		$password = $this->createElement ( 'password', 'password' );
		$password->addValidator ( 'StringLength', false, array (6 ) )
        	     ->setRequired ( true )
        	     ->setLabel('Mật khẩu')
                     ->setAttrib('class', 'input-medium');
		
        	     
		$submit = $this->createElement('submit','login',array ('label' => 'Đăng nhập' ));
                $submit->setAttrib('class', 'btn btn-large');
		$remember = $this->createElement('checkbox','remember',array ('label'	=> 'Ghi nhớ đăng nhập'));
		$this->addElement($user_name)
				->addElement($password)
				->addElement($remember)
				->addElement($submit);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
				'ViewHelper',
				'Errors',
				'Description',
				array(
						array('data'	=> 'HtmlTag'),
						array('tag'		=> 'div','class'	=> 'controls')),
				array('label',
						array('class'	=> 'control-label')),
				array(
						array('row'	=> 'HtmlTag',),
						array('class'=>'control-group ')
				),
				array(
						array('ErrorsDiv' => 'HtmlTag'),
						array('tag' => 'span', 'placement' => Zend_Form_Decorator_Abstract::APPEND)
				)
		)
		);
		$submit->setDecorators(array(
								'ViewHelper',
								array(
									array('data'	=> 'HtmlTag'),
									array('tag'		=>	'div')
								),
								array(
									array('emptyrow'	=> 'HtmlTag'),
									array('tag'			=> 'div',
											'placement'	=> 'PREPEND')),
								array(
									array('row'	=> 'HtmlTag'),
									array('tag'	=> 'div'))
									));
		$remember->setDecorators(array(
								'ViewHelper',
								array(
									array('data'	=> 'HtmlTag'),
									array('tag'		=>	'span','for'=>'remember')
								),
								array('label',
											array('tag'	=> 'span','placement'	=> Zend_Form_Decorator_PrepareElements::APPEND)),
								array(
									array('row'	=> 'HtmlTag'),
									array('tag'	=> 'div'))
									));
	}

}